package cn.mado.org.service.impl;

import cn.mado.basic.util.PageList;
import cn.mado.org.domain.Picture;
import cn.mado.org.domain.User;
import cn.mado.org.mapper.PictureMapper;
import cn.mado.org.query.PictureQuery;
import cn.mado.org.service.PictureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PictureServiceImpl implements PictureService {

    @Autowired
    private PictureMapper pictureMapper;

    @Override
    public List<Picture> findAll() {
        return pictureMapper.findAll();
    }

    @Override
    public void add(Picture picture) {
        pictureMapper.add(picture);
    }

    @Override
    public void update(Picture picture) {
        pictureMapper.update(picture);
    }

    @Override
    public void delete(Long picId) {
        pictureMapper.delete(picId);
    }

    @Override
    public Picture findById(Long picId) {
        return pictureMapper.findById(picId);
    }

    @Override
    public PageList<Picture> queryByPage(PictureQuery query) {
        Integer totals = pictureMapper.queryByCount(query);
        List<Picture> users = pictureMapper.queryByPage(query);
        return new PageList<Picture>(totals,users);
    }
}
